package com.tool.btn;

import com.tool.role.RoleData;
import com.tool.tcpimg.UIUtils;
import org.apache.commons.lang.StringUtils;
import org.come.Frame.ZhuFrame;
import org.come.Jpanel.ChooseLiangHaoTypeJpanel;
import org.come.Jpanel.DepositListJpanel;
import org.come.Jpanel.TestPetJpanel;
import org.come.bean.LoginResult;
import org.come.entity.RoleSummoning;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.until.FormsManagement;
import org.come.until.UserMessUntil;
import org.wing.panel.LHMainFrame;
import org.wing.panel.WingMainFrame;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;

public class ChooseLhBtn extends MoBanBtn {
    //0上 1下 2顶 3底
    private ChooseLiangHaoTypeJpanel jpanel;
    private int p;

    public ChooseLhBtn(String iconpath, int type, Color[] colors,
                       Font font, String text, Integer typeBtn, ChooseLiangHaoTypeJpanel jpanel) {
        // TODO Auto-generated constructor stub
        super(iconpath, type, colors);
        this.setText(text);
        this.setFont(UIUtils.TEXT_HY16);
        setVerticalTextPosition(SwingConstants.CENTER);
        setHorizontalTextPosition(SwingConstants.CENTER);
        this.p=p;
        this.jpanel = jpanel;
    }


    @Override
    public void chooseyes() {

    }

    @Override
    public void chooseno() {

    }

    @Override
    public void nochoose(MouseEvent e) {

        if(this.getText().equals("炼化")){
            int type = 6;
            String lianghaoValue = RoleData.getRoleData().getLoginResult().getLianghaoValue();
            if(StringUtils.isNotBlank(lianghaoValue) && lianghaoValue.contains("@")){
                String[] split = lianghaoValue.split("@");
                type = Integer.parseInt(split[0]);
            }else{
                type = 6;
            }

            FormsManagement.showForm(866);
            LHMainFrame.LHMainFrame().getLhMainPanel().changLeftType(type);
            return;
        }
        //获取当前选中的位置
        int w=jpanel.getListLh().getSelectedIndex();
        if (w==-1) {
            return;
        }
        String mes = Agreement.getAgreement().setLiangHaoType("LHTYPE=" + String.valueOf(w));
        SendMessageUntil.toServer(mes);
        LoginResult loginResult = RoleData.getRoleData().getLoginResult();
        loginResult.setLianghaotype(Integer.valueOf(w));
    }
}
